package com.hzj.controller.api;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hzj.pojo.*;
import com.hzj.service.PlatformNoticeService;
import com.hzj.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/hosp/hospital")
public class PlatformNoticeController {

    @Autowired
    private  PlatformNoticeService ps;

    //查询加分页
    @PostMapping("/plat/{page}/{limit}")
    public Result platList(@PathVariable Integer page, @PathVariable Integer limit){

        Page page1 = new Page(page, limit);

        Page page2 = ps.page(page1);

       return Result.ok(page2);
    }

    //根据查询
    @PostMapping("/getPlat/{id}")
   public  PlatformNotice getPlat(@PathVariable Integer id) {
        QueryWrapper wrapper = new QueryWrapper();
        wrapper.eq("id", id);
        PlatformNotice one = ps.getOne(wrapper);
        return one;
    }

    //增加
    @PostMapping("/plat/addPlat")
    Boolean addPlat(@RequestBody PlatformNotice pn) {

        return ps.save(pn);
    }

    //删除
    @PostMapping("/delPlat/{id}")
    Boolean delPlat(@PathVariable Integer id) {

        return ps.removeById(id);
    }

    //修改
    @PostMapping("/plat/updatePlatById")
    Boolean updatePlatById(@RequestBody PlatformNotice pn) {

        return ps.updateById(pn);
    }



}
